//
//  KLNumberPadButton.m
//  KLCurrency
//
//  Created by apple on 2018/1/3.
//  Copyright © 2018年 bonc. All rights reserved.
//

#import "KLNumberPadButton.h"

@implementation KLNumberPadButton

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super initWithCoder:aDecoder]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    [self setBackgroundImage:[self imageWithColor:UIColorFromRGB(0x313943)] forState:UIControlStateNormal];
    [self setBackgroundImage:[self imageWithColor:UIColorFromRGB(0x101216)] forState:UIControlStateHighlighted];
}

- (UIImage *)imageWithColor:(UIColor *)color {
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return image;
}

//- (void)setHighlighted:(BOOL)highlighted {
//    [super setHighlighted:highlighted];
//    if (highlighted) {
//        self.backgroundColor = UIColorFromRGB(0x101216);
//    } else {
//        self.backgroundColor = UIColorFromRGB(0x313943);
//    }
//}




//- (void)setHighlighted:(BOOL)highlighted {
//  [super setHighlighted:highlighted];
//    
//
//}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
